<template>
	<view class="all">
		<!-- 头部 -->
		<view class="header">
			<view class="integral">
				签约余额
			</view>
			<view class="integral_mount" v-cloak>
				{{res.qianyue_inter}}
			</view>
		</view>	
		<!-- 充值签约 -->
		<view class="uni-list">
			<view class="uni-list-cell" @click="sign">
				<view class="uni-list-cell-navigate uni-navigate-right">
					<text class="iconfont">&#xe601;</text>
					<text class="text">充值签约</text>
				</view>
			</view>
		</view>
		<!-- 签约记录 -->
		<view class="recording">签约记录</view>
		<!-- 展示充值签约详细信息列表 -->
		<view class="fui-list goods-item ">
			<view class="fui-list-inner">
				<!-- 普通签约订单 -->
				<view class="list-cell" v-for="(value,key) in res.list" :key="key">
					<view class="left">
						<view class='title' v-if="value.coin == 'alipay'" v-cloak>支付宝充值:{{value.money}}元 (实际支付￥{{value.shiji}}元)</view>
						<view class='title' v-if="value.coin == 'wechat'" v-cloak>微信充值:{{value.money}}元 (实际支付￥{{value.shiji}}元)</view>
						<view class='title' v-if="value.coin == 'bank'" v-cloak>银行卡充值:{{value.money}}元 (实际支付￥{{value.shiji}}元)</view>
						<view class='text' v-cloak>{{value.createtime}}</view>
						<view class='text' v-cloak>订单号：{{value.logno}}</view>
						<view v-if="value.coin == 'bank'">
							<view class='text' v-cloak>开户行：{{value.skfs}}</view>
							<view class='text' v-cloak>户名：{{value.name}}</view>
							<view class='text' v-cloak>账号：{{value.zhanghao}}</view>
						</view>
					</view>
					<view class="right">
						<text class='fui-list-angle' v-if="value.qystatus == 0 && value.status == 1"><text class='fui-label' style="background: yellowgreen">可激活</text></text>
						<text class='fui-list-angle' v-else-if="value.qystatus == 1 && value.fenqi == 0"><text class='fui-label' style="background: green">签约成功</text></text>
						<text class='fui-list-angle' v-else><text class='fui-label' style="background: yellowgreen">签约中</text></text>
					</view>
				</view>	
				<!-- 分期订单 -->
				<view class="list-cell" v-for="(value,index) in res.flog" :key="index">
					<view class="left">
						<view class='title' v-if="value.coin == 'alipay'" v-cloak>支付宝充值:{{value.money}}元 (实际支付￥{{value.shiji}}元)</view>
						<view class='title' v-if="value.coin == 'wechat'" v-cloak>微信充值:{{value.money}}元 (实际支付￥{{value.shiji}}元)</view>
						<view class='title' v-if="value.coin == 'bank'" v-cloak>银行卡充值:{{value.money}}元 (实际支付￥{{value.shiji}}元)</view>
						<view class='text' v-cloak>{{value.createtime}}</view>
						<view class='text' v-cloak>订单号：{{value.logno}}</view>
						<view v-if="value.coin == 'bank'">
							<view class='text' v-cloak>开户行：{{value.skfs}}</view>
							<view class='text' v-cloak>户名：{{value.name}}</view>
							<view class='text' v-cloak>账号：{{value.zhanghao}}</view>
						</view>
					</view>
					<view class="right">
						<text class='fui-list-angle' v-if="value.status == 6"><text class='fui-label' style="background: yellowgreen">充值中</text></text>
						<text class='fui-list-angle' v-if="value.status == 1"><text class='fui-label' style="background: #ff9326">已充值</text></text>
					</view>
				</view>	
			</view>
		</view>
	</view>
	
</template>

<script>
	// import tabBar from '../../../components/tab-nvue/tabBar.nvue';
	export default {
		components: {
			// tabBar
		},
		data() {
			return {
				res:[],
				contract:[],
				agentid:'',
				new_log_no:'',
				openid:'',
				active:"active"
			};
		},
		onLoad:function(){
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		methods:{
			setAjax(){
				uni.request({
					url: 'http://hszj.hongshantang696.com//app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=coin.balance&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						uni.hideLoading()
						this.res = res.data
						console.log(this.res)
						if(this.res.tk != '' && this.res.tk.fenqi == 0) {
							uni.showModal({
							content:'恭喜您，您的转账申请已经通过，请尽快签署分红协议，点击确定立即签署',
							showCancel: true,
							confirmColor:"#DD524D",
							success(res) {
								if (res.confirm) {
										uni.navigateTo({
											url: './pay_aggrement'
										});
									}
									return
								}
							})
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			jumpcoin(e){
				var id =e.currentTarget.dataset.id
				uni.navigateTo({
					url: 'mingxi?id='+ id
				});
			},
			jump(e){
				var src =e.currentTarget.dataset.src
				uni.navigateTo({
					url: src
				});
			},
			sign(){
				uni.request({
					url: 'http://hszj.hongshantang696.com//app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.baodan&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						uni.hideLoading()
						this.contract = res.data
						this.agentid = res.data.agentid
						this.new_log_no = res.data.new_log_no
						if(this.contract.error == 1) {
							// 弹窗
							uni.showModal({
							content:this.contract.message,
							showCancel: false,
							confirmColor:"#DD524D",
							success(res) {
								if (res.confirm) {
									return
									}
								}
							})
						} else {
							// 跳转到在线充值签约页面
							uni.navigateTo({
								url: './onlinesign?agentid='+this.agentid+'&new_log_no='+this.new_log_no
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style>
.header {
	background-color: #175e3c;
	text-align: center;
	padding: 40upx 20upx;
	color: #fff;
}
.integral {
	font-size: 30upx;
	font-weight: 520;
}
.integral_mount {
	font-size: 70upx;
	font-weight: 600;
}
.recording {
	text-align: center;
	margin: 30upx 0 20upx 0;
}
.uni-list-cell.active {
	background:#f5f5f5;
}
.uni-list image {
	width:34upx;
	height:34upx;
}
.uni-list .text {
	position:absolute;
	left:84upx;
	font-size:26upx;
}
.uni-list {
	margin-top:20upx;
}
.uni-list:before,.uni-list:after {
	display:none;
}
.uni-list-cell:after {
	content:" ";
	position:absolute;
	left:0.5rem;
	right:0.5rem;
	bottom:-1px;
	height:1px;
	border-top:1px solid #ebebeb;
	color:#D9D9D9;
	-webkit-transform-origin:0 0;
	-ms-transform-origin:0 0;
	transform-origin:0 0;
	-webkit-transform:scaleY(0.5);
	-ms-transform:scaleY(0.5);
	transform:scaleY(0.5);
	background:none;
}
.uni-list-cell .right {
	font-size:24upx;
	color:#999;
	margin-right:20upx;
}
.uni-list .uni-list-cell:last-child:after {
	border:0;
}
.uni-navigate-right .iconfont {
	color: orange;
}
.list-cell {
	display: flex;
	background-color: #fff;
	align-items: center;
	color: #666;
	border-bottom: 2upx solid #eaeaea;
	padding: 10upx 15upx;
}
.left {
	flex: 4;
}
.right {
	flex: 1;
	text-align: center;
}
.title {
	color: #000000;
}
.fui-label {
	color: #fff;
}
</style>
